<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./react/react17.development.js"></script>
    <script src="./react/react-dom17.development.js"></script>
    <script src="./react/babel.min.js"></script>
</head>

<body>
    <div id="main"></div>
    <script type="text/babel">
        class Com extends React.Component {
            render() {
                return (<div>
                    <button onClick={this.run}>事件1</button>
                    <button onClick={this.run2}>事件2</button>
                    <button onClick={(e)=>{  // 当前事件函数是箭头函数
                        console.log("事件函数",this);  //  当前组件
                        console.log("事件函数",e); // 当前组价
                        this.run3(e);
                    }}>事件3</button>
                    <button onClick={(e)=>this.run4(e)}>事件4</button>
                    <button onClick={this.run5.bind(this)}>事件5</button>
                <button onClick={this.run11}>事件11</button>
                
                    </div>)
            }

            run11(){
                console.log("run函数111",this);
            }
            run5() {    
                console.log("run5555555555", this);// 当前组件
            }
            run4(e){
                console.log("run444444444444", this);// 当前组件
                console.log(e);
            }
            run() {     //  run=function(){}
                console.log("run函数", this);// undefined  this丢失
            }
            run2=()=>{
                console.log("run2", this);// 当前组件
            }
            run3(e){
                console.log("run333", this);// 当前组件
                console.log(e);
            }
        }
        ReactDOM.render(<Com />, document.getElementById("main"))
   
    </script>
</body>

</html>